﻿using System.Collections.Generic;
using System.Linq;
using Missbot.Common;
using Dolany.UtilityTool;
using Missbot.Core.CrossingRoute;

namespace Missbot.AIModule.Pet.Cooking
{
    public class CookingDietSvc : IDataMgr, ISingleton, IViewable, ILearnable, IExchangable
    {
        public List<CookingDiet> DietList;

        public CookingDiet this[string name] => DietList.FirstOrDefault(p => p.Name == name);

        public CookingDiet SuggestDiet(List<string> LearnedDiets)
        {
            var availables = DietList.Where(p => !LearnedDiets.Contains(p.Name));
            return availables.RandElement();
        }

        public void RefreshData()
        {
            DietList = CookingDietDA.GetAll();
        }

        public (bool canView, string viewCommand) ViewableCheck(string name)
        {
            return this[name] == null ? (false, null) : (true, "查看菜肴");
        }

        public (bool canLearn, string learnCommand) LearnableCheck(string name)
        {
            return this[name] == null ? (false, null) : (true, "学习菜谱");
        }

        public (bool canExchange, string exchangeCommand) ExchangableCheck(string name)
        {
            return this[name] == null ? (false, null) : (true, "兑换菜谱");
        }
    }
}